<!-- 辅助器具设配详情 -->
<template>
  <el-card>
    <el-page-header @back="$router.go(-1)" content="基本康复活动详情" />
    <div class="app-container">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="基本康复信息" name="first">
          <el-row :gutter="30" class="mt10">
            <el-col :span="12">
              <el-descriptions :column="2" border>
                <el-descriptions-item label="基本康复标题">{{currentData.assistActivityTitle}}</el-descriptions-item>
                <el-descriptions-item label="活动进度">
                  <el-tag size="small">{{ activitiesStatus[currentData.status] }}</el-tag>
                </el-descriptions-item>
                <el-descriptions-item label="开始时间">{{ currentData.startTime }}</el-descriptions-item>
                <el-descriptions-item label="结束时间">{{ currentData.endTime }}</el-descriptions-item>
                <el-descriptions-item label="康复活动说明">{{ currentData.assistActivityDesc }}</el-descriptions-item>
              </el-descriptions>
            </el-col>
            <el-col :span="12">
              <el-descriptions :column="1" border>
                <template v-if="[2,3,4,5].includes(currentData.status)">
                  <el-descriptions-item label="鉴定机构" v-if="currentData.chooseInstituteInfos && currentData.chooseInstituteInfos.length">
                    <el-tag v-for="(tag,index) in currentData.chooseInstituteInfos" :key="index">
                      {{ tag.name +'_'+ tag.disabledTypeName }}
                    </el-tag>
                  </el-descriptions-item>
                </template>
                <template v-if="[4,5].includes(currentData.status)">
                  <el-descriptions-item label="附件" v-if="currentData.financeUrl">
                    <div
                      v-for="(item, index) in JSON.parse(currentData.financeUrl)"
                      :key="index"
                      @click="previewDetail(item.id)"
                    >
                      <a class="article_title_a"><i class="el-icon-files mr5" />
                        {{ item.fileName }}
                      </a>
                    </div>
                  </el-descriptions-item>
                  <el-descriptions-item label="供应商" v-if="currentData.serviceInfos && currentData.serviceInfos.length">
                    <el-tag v-for="(tag,index) in currentData.serviceInfos" :key="index">
                      {{ tag.name +'_'+ tag.disabledTypeName }}
                    </el-tag>
                  </el-descriptions-item>
                </template>
              </el-descriptions>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="辅助器具申请列表" name="second">
          <el-form ref="form" :model="searchDto" inline label-suffix=":">
            <el-form-item label="姓名" prop="userName">
              <el-input
                v-model="searchDto.userName"
                placeholder="请输入残疾人姓名"
                style="width:250px"
              />
            </el-form-item>
            <el-form-item label="残疾类别" prop="disabledTypeId" label-width="90px">
              <el-select v-model="searchDto.disabledTypeId" placeholder="请选择残疾类别">
                <el-option
                  v-for="item in getDictionary('DIS_TYPE')"
                  :key="item.id"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="器具分类" prop="cid" label-width="90px">
              <el-select v-model="searchDto.cid" placeholder="请选择器具分类">
                <el-option
                  v-for="item in getDictionary('ASSIST_EQU_CATEGOTY')"
                  :key="item.id"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="适配进度" prop="status" label-width="90px">
              <el-select v-model="searchDto.status" placeholder="请选择适配进度">
                <el-option
                  v-for="(label,value) in applianceApplicationStatus"
                  :key="value"
                  :label="label"
                  :value="value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="地区" prop="region">
              <el-cascader
                style="width:400px"
                clearable
                v-model="region"
                :props="props"
                placeholder="请选择地区"
              ></el-cascader>
            </el-form-item>
            <el-form-item>
              <el-button icon="el-icon-search" type="primary" @click="search('辅助器具')">查询</el-button>
              <el-button icon="el-icon-s-open" type="primary" @click="clear('辅助器具')">重置</el-button>
              <el-button
                icon="el-icon-upload2"
                type="success"
                :loading="loading"
                @click="exportXlsx()"
              >导出
              </el-button>
            </el-form-item>
          </el-form>
          <page-table
            ref="table"
            :page-data="pageData"
            :loading="loading"
            :do-get-page-data="getPageData"
          >
            <el-table-column type="index" label="编号" width="60" align="center" />
            <el-table-column prop="userName" label="姓名" align="center" />
            <el-table-column prop="region" label="地区" align="center" />
            <el-table-column prop="receiveAddress" label="收货地址" align="center" />
            <el-table-column prop="disabledTypeId" label="残疾类别" align="center">
              <template slot-scope="scope">
                {{ scope.row.disabledTypeId | keyTextById("DIS_TYPE") }}
              </template>
            </el-table-column>
            <el-table-column prop="cid" label="器具分类" align="center">
              <template slot-scope="scope">
                {{ scope.row.cid | keyTextById("ASSIST_EQU_CATEGOTY") }}
              </template>
            </el-table-column>
            <el-table-column prop="assistEquName" label="所选器具" align="center" />
            <el-table-column prop="assistEquImageUrl" label="器具图片" align="center">
              <template slot-scope="scope" v-if="scope.row.status != 0">
                <el-image
                  style="width:100px"
                  :src="getImage(scope.row.assistEquImageUrl)"
                  :preview-src-list="[getImage(scope.row.assistEquImageUrl)]"
                />
              </template>
            </el-table-column>
            <el-table-column prop="status" label="状态" align="center">
              <template slot-scope="scope">
                <el-tag size="small">
                  {{ applianceApplicationStatus[scope.row.status] }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="applyType" label="申请类型" align="center" />
            <el-table-column prop="applyReason" label="申请备注" align="center" show-overflow-tooltip/>
            <el-table-column prop="reason" label="审核备注" align="center" show-overflow-tooltip/>
            <el-table-column label="操作" align="center" width="180" fixed="right">
              <template slot-scope="scope">
                <el-tooltip v-if="currentData.status != 5 && scope.row.status != '-3'" content="取消适配" placement="top">
                  <el-button
                    type="warning"
                    size="mini"
                    icon="el-icon-refresh-right"
                    @click="rejectApplication(scope.row,'cancel')"
                  />
                </el-tooltip>
                <el-tooltip
                  content="驳回"
                  placement="top"
                  v-if="scope.row.status == 3"
                >
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-close"
                    @click="rejectApplication(scope.row,'reject')"
                  />
                </el-tooltip>
                <el-tooltip content="详情" placement="top" v-if="scope.row.status!=='0'">
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-view"
                    @click="viewApplication(scope.row)"
                  />
                </el-tooltip>
              </template>
            </el-table-column>
          </page-table>
        </el-tab-pane>
        <el-tab-pane label="基本康复申请列表" name="basic">
          <el-form ref="form1" :model="searchDto" inline label-suffix=":">
            <el-form-item label="姓名" prop="userName">
              <el-input
                v-model="searchDto.userName"
                placeholder="请输入残疾人姓名"
                style="width:250px"
              />
            </el-form-item>
            <el-form-item label="残疾类别" prop="disabledTypeId" label-width="90px">
              <el-select v-model="searchDto.disabledTypeId" placeholder="请选择残疾类别">
                <el-option
                  v-for="item in getDictionary('DIS_TYPE')"
                  :key="item.id"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="适配进度" prop="status" label-width="90px">
              <el-select v-model="searchDto.status" placeholder="请选择适配进度">
                <el-option
                  v-for="(label,value) in applianceApplicationStatus"
                  :key="value"
                  :label="label"
                  :value="value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="地区" prop="region">
              <el-cascader
                style="width:400px"
                clearable
                v-model="region"
                :props="props"
                placeholder="请选择地区"
              ></el-cascader>
            </el-form-item>
            <el-form-item>
              <el-button icon="el-icon-search" type="primary" @click="search('基本服务')">查询</el-button>
              <el-button icon="el-icon-s-open" type="primary" @click="clear('基本服务')">重置</el-button>
              <el-button
                icon="el-icon-upload2"
                type="success"
                :loading="loading"
                @click="exportXlsx()"
              >导出
              </el-button>
            </el-form-item>
          </el-form>
          <page-table
            ref="table"
            :page-data="pageData"
            :loading="loading"
            :do-get-page-data="getPageData"
          >
            <el-table-column type="index" label="编号" width="60" align="center" />
            <el-table-column prop="userName" label="姓名" align="center" />
            <el-table-column prop="region" label="地区" align="center" />
            <el-table-column prop="receiveAddress" label="收货地址" align="center" />
            <el-table-column prop="disabledTypeId" label="残疾类别" align="center">
              <template slot-scope="scope">
                {{ scope.row.disabledTypeId | keyTextById("DIS_TYPE") }}
              </template>
            </el-table-column>
            <el-table-column prop="assistEquName" label="所选基本服务" align="center" />
            <el-table-column prop="status" label="状态" align="center">
              <template slot-scope="scope">
                <el-tag size="small">
                  {{ applianceApplicationStatus[scope.row.status] }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="applyType" label="申请类型" align="center" />
            <el-table-column prop="applyReason" label="申请备注" align="center" show-overflow-tooltip/>
            <el-table-column prop="reason" label="审核备注" align="center" show-overflow-tooltip/>
            <el-table-column label="操作" align="center" width="180" fixed="right">
              <template slot-scope="scope">
                <el-tooltip v-if="currentData.status != 5 && scope.row.status != '-3'" content="取消适配" placement="top">
                  <el-button
                    type="warning"
                    size="mini"
                    icon="el-icon-refresh-right"
                    @click="rejectApplication(scope.row,'cancel')"
                  />
                </el-tooltip>
                <el-tooltip
                  content="驳回"
                  placement="top"
                  v-if="scope.row.status == 3"
                >
                  <el-button
                    type="danger"
                    size="mini"
                    icon="el-icon-close"
                    @click="rejectApplication(scope.row,'reject')"
                  />
                </el-tooltip>
                <el-tooltip content="详情" placement="top" v-if="scope.row.status!=='0'">
                  <el-button
                    type="success"
                    size="mini"
                    icon="el-icon-view"
                    @click="viewApplication(scope.row)"
                  />
                </el-tooltip>
              </template>
            </el-table-column>
          </page-table>
        </el-tab-pane>
      </el-tabs>
      <div class="bottom-btn mt40">
        <!-- <el-button
          type="success"
          class="mr10"
          @click="chooseBodies"
          v-if="currentData.status === 1"
        >
          选择鉴定机构
        </el-button> -->
        <el-button
          type="success"
          class="mr10"
          v-if="currentData.status === 2 || currentData.status === 1"
          @click="submitFinance"
        >提交财政
        </el-button>
        <el-button
          type="primary"
          class="mr10"
          v-if="currentData.status === 3"
          @click="financialInformation"
        >上传财政资料
        </el-button>
        <el-button
          type="warning"
          class="mr10"
          v-if="currentData.status === 4"
          @click="endConfirm"
        >确认完结
        </el-button>
      </div>
    </div>
    <el-dialog width="40%" :visible.sync="showFinancialInformation" title="上传财政资料" @close="closeFile">
      <el-row>
        <el-form ref="fileForm" :rules="rules" :model="formInfo" label-width="auto" label-suffix="：">
          <el-form-item label="选择文件" prop="financeUrl">
            <el-upload
              class="upload-demo"
              :action="imgHead"
              :headers="head"
              :on-success="handleSuccess"
              :on-remove="handleRemove"
              :before-remove="beforeRemove"
              multiple
              :limit="5"
              :on-exceed="handleExceed"
              :file-list="fileList"
            >
              <el-button size="small" type="primary">点击上传</el-button>
            </el-upload>
          </el-form-item>
          <el-form-item label="服务商" prop="submitFileServiceInfoDtos">
            <div v-for="(item,index) in serviceList" :key="index" style="display: block">
              <span style="font-size: 13px;margin-right: 10px">
                {{ item.disabledTypeName+'：' }}
              </span>
              <el-radio-group v-model="serviceList[index].current">
                <el-radio :label="v" border v-for="(v,i) in item.serviceInfos" :key="i">
                  {{ v.name }}
                </el-radio>
              </el-radio-group>
            </div>
          </el-form-item>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button type="primary" @click="confirm">确定</el-button>
        <el-button @click="closeFile">取消</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="showChooseBodies" title="选择鉴定机构" @close="close">
      <el-row>
        <el-form
          ref="fileForm1"
          :rules="rules1"
          :model="formInfo1"
          label-width="auto"
          label-suffix="："
        >
          <el-form-item label="鉴定机构" prop="instituteInfoDtos">
            <div v-for="(item,index) in serviceList" :key="index" style="display: block">
              <span style="font-size: 13px;margin-right: 10px">
                {{ item.disabledTypeName+'：' }}
              </span>
              <el-radio-group v-model="serviceList[index].current">
                <el-radio :label="v" border v-for="(v,i) in item.serviceInfos" :key="i">
                  {{ v.name }}
                </el-radio>
              </el-radio-group>
            </div>
          </el-form-item>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button type="primary" @click="confirmBodies">确定</el-button>
        <el-button @click="close">取消</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="showApplianceInfo" title="申请详情">
      <el-descriptions :column="2" border :labelStyle="{'width':'110px'}">
        <el-descriptions-item label="活动名称">
          {{ assistActivityInfo.assistActivityTitle }}
        </el-descriptions-item>
        <el-descriptions-item label="活动状态">
          <el-tag size="mini">{{ applianceApplicationStatus[assistEquApplyInfo.status] }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="收货联系人">
          {{ assistEquApplyInfo.receiveContact }}
        </el-descriptions-item>
        <el-descriptions-item label="联系电话">
          {{ assistEquApplyInfo.receiveContactNum }}
        </el-descriptions-item>
        <el-descriptions-item label="收货地址">
          {{ assistEquApplyInfo.receiveAddress }}
        </el-descriptions-item>
        <el-descriptions-item label="申请备注">
          {{ assistEquApplyInfo.applyReason }}
        </el-descriptions-item>
        <el-descriptions-item label="审核备注" v-if="assistEquApplyInfo.reason">
          {{ assistEquApplyInfo.reason }}
        </el-descriptions-item>
        <el-descriptions-item label="身份证正面" v-if="assistEquApplyInfo.idCardFrontUrl">
          <el-image
            style="width: 70%;height: 70%"
            :src="getImage(assistEquApplyInfo.idCardFrontUrl)"
            :preview-src-list="[getImage(assistEquApplyInfo.idCardFrontUrl)]"
          />
        </el-descriptions-item>
        <el-descriptions-item label="身份证反面" v-if="assistEquApplyInfo.idCardBackUrl">
          <el-image
            style="width: 70%;height: 70%"
            :src="getImage(assistEquApplyInfo.idCardBackUrl)"
            :preview-src-list="[getImage(assistEquApplyInfo.idCardBackUrl)]"
          />
        </el-descriptions-item>
        <el-descriptions-item label="已选服务" v-if="assistEquInfo && assistEquInfo.assistEquName">
          {{ assistEquInfo.assistEquName }}
        </el-descriptions-item>
        <el-descriptions-item label="残疾状况图片" v-if="assistEquApplyInfo.disabilityPictureUrl">
          <el-image
            style="width: 70%;height: 70%"
            :src="getImage(assistEquApplyInfo.disabilityPictureUrl)"
            :preview-src-list="[getImage(assistEquApplyInfo.disabilityPictureUrl)]"
          />
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions
        v-if="assistEquApplyInfo.instituteOnSitePhoto"
        title="服务商评估记录"
        style="margin-top: 20px"
        :column="2"
        border
      >
        <el-descriptions-item label="审核备注">
          {{ assistEquApplyInfo.instituteRecord }}
        </el-descriptions-item>
        <el-descriptions-item label="审核图片">
          <div style="display: flex">
            <el-image
              style="width: 250px;height: 250px"
              v-for="(j,k) in assistEquApplyInfo.instituteOnSitePhoto.split(',')"
              :key="k"
              :src="getImage(j)"
              :preview-src-list="assistEquApplyInfo.instituteOnSitePhoto.split(',').map(v=>getImage(v))"
            />
          </div>
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions
        v-if="assistEquApplyInfo.finishOnSitePhoto"
        title="发货记录"
        style="margin-top: 20px"
        :column="2"
        border
      >
        <el-descriptions-item label="发货信息">
          {{ assistEquApplyInfo.finishRecord }}
        </el-descriptions-item>
        <el-descriptions-item label="发放时间">
          {{ assistEquApplyInfo.finishTime}}
        </el-descriptions-item>
        <el-descriptions-item label="发货图片信息">
          <div style="display: flex">
            <el-image
              style="width: 250px;height: 250px"
              v-for="(j,k) in assistEquApplyInfo.finishOnSitePhoto.split(',')"
              :key="k"
              :src="getImage(j)"
              :preview-src-list="assistEquApplyInfo.finishOnSitePhoto.split(',').map(v=>getImage(v))"
            />
          </div>
        </el-descriptions-item>
      </el-descriptions>
    </el-dialog>

    <el-dialog
      :visible.sync="rejectShow"
      v-if="rejectShow"
      :title="modalTypeMap[modalType].title"
      width="700px"
      @close="closeReject"
    >
      <el-form ref="rejectForm" :model="rejectForm" :rules="rejectRule" label-suffix=":" label-width="auto">
        <el-form-item label="备注内容" prop="reason">
          <el-input
            type="textarea"
            :autosize="{minRows:4}"
            v-model="rejectForm.reason"
            placeholder="请输入备注内容"
          />
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="handleReject">确定</el-button>
        <el-button @click="closeReject">取消</el-button>
      </div>
    </el-dialog>
  </el-card>
</template>
<script>
export default {
  name: "AdaptationInfo",
  data() {
    return {
      rejectForm: {},
      rejectShow: false,
      rejectRule: {
        body: [{ required: true, message: "请输入内容", trigger: "blur" }],
      },
      showChooseBodies: false,
      loading: false,
      props: {
        label: "name",
        value: "id",
        leaf: "isLeaf",
        lazy: true,
        lazyLoad: this.lazyLoad,
        checkStrictly: true
      },
      region: [],
      currentData: {},
      activeName: 'first',
      searchDto: {
        pageIndex: 1,
        pageSize: 10,
        applyType: '',
        disabledTypeId: null,
        cid: null,
        status: null,
      },
      fileList: [],
      rules: {
        financeUrl: [{ required: true, message: "请上传文件", trigger: "blur" }],
        submitFileServiceInfoDtos: [{ required: true, message: "请选择服务商", trigger: "blur" }]
      },
      rules1: {
        submitFileServiceInfoDtos: [{ required: true, message: "请选择鉴定机构", trigger: "blur" }]
      },
      formInfo: {
        submitFileServiceInfoDtos: [],
        financeUrl: null
      },
      formInfo1: {
        instituteInfoDtos: [],
      },
      showFinancialInformation: false,
      serviceList: [],
      pageData: {},
      activitiesStatus: {
        0: "活动未开始",
        1: "活动进行中",
        2: "机构鉴定中",
        3: "待上传财政资料",
        4: "备货中",
        5: "活动完结"
      },
      applianceApplicationStatus: {
        '-3': '取消适配',
        '-2': '鉴定机构驳回',
        '-1': "残联驳回",
        0: "未申请",
        1: "待选择鉴定机构",
        2: "鉴定机构审核中",
        3: "残联审核中",
        4: "待上传财政资料",
        5: "备货中",
        6: "待评价",
        7: "已评价",
      },
      imgHead: window.api.sysUploadUrl + "?path=disabled",
      head: {
        userRole: "ADMIN",
        token: window.sessionStorage.getItem("token")
      },
      showApplianceInfo: false,
      assistActivityInfo: {},
      assistEquApplyInfo: {},
      assistEquInfo: {},
      modalType: null,
      modalTypeMap: {
        'reject': { title: '残联驳回:', confirmTips: "是否确认驳回?", api: 'backApply' },
        'cancel': { title: '取消申请:', confirmTips: "是否确认取消?", api: 'cancelApply' }
      }
    }
  },
  methods: {
    closeReject() {
      this.rejectForm = {}
      this.rejectShow = false
    },
    close() {
      this.showChooseBodies = false
      this.formInfo1 = {}
    },
    // 导出
    exportXlsx() {
      this.loading = true
      this.searchDto.region = this.region.length ?
        this.region[this.region.length - 1] : null
      Object.assign(this.searchDto, { activityId: this.currentData.id })
      let fileDownload = require("js-file-download");
      this.ExportApi.exportApplyUserInfoById(this.searchDto).then(ret => {
        this.loading = false
        fileDownload(ret.data, "辅助器具申请.xlsx");
        this.success('导出成功')
      })
    },
    lazyLoad(node, resolve) {
      let query = { level: 1, pid: 0 };
      if (node.level !== 0) {
        let { id, level } = node.data;
        query = {
          level: level + 1,
          pid: id
        };
      }
      this.API.getSysAreaByLevelAndPid(query).then(ret => {
        // 设置叶子节点
        ret.data.map(i => {
          if (i.level == 5 || i.name == "市辖区") {
            i.isLeaf = true;
          }
        });
        resolve(ret.data);
      });
    },
    previewDetail(val) {
      this.openTabPage(
        window.api.preFile +
        "?url=" +
        window.api.secretFilePreview +
        val +
        "?token=" +
        window.sessionStorage.getItem("token")
      );
    },
    getImage(url) {
      return window.api.image + '/' + url
    },

    viewApplication(row) {
      this.API.getAssistEquApplyInfoById({ applyId: row.id }).then(ret => {
        const { assistActivityInfo, assistEquApplyInfo, assistEquInfo } = ret.data
        this.assistActivityInfo = assistActivityInfo
        this.assistEquApplyInfo = assistEquApplyInfo
        this.assistEquInfo = assistEquInfo
        this.showApplianceInfo = true
      })
    },

    // 取消/驳回
    handleReject() {
      this.$refs["rejectForm"].validate(valid => {
        if (valid) {
          const { confirmTips, api } = this.modalTypeMap[this.modalType]
          this.$confirm(confirmTips, "提示", { type: "warning" }).then(() => {
            let { applyId, reason } = this.rejectForm

            this.API[api]({ applyId, reason }).then(() => {
              this.success('操作成功')
              this.closeReject()
              this.getPageData()
              this.activeName = 'second'
            })
          }).catch(() => {
          })
        }
      })
    },

    rejectApplication({ id }, type) {
      this.modalType = type
      this.rejectForm.applyId = id
      this.rejectShow = true
    },

    // 确定完结
    endConfirm() {
      this.$confirm("是否确认完结?", "提示", { type: "warning" }).then(() => {
        this.API.finishActivity({ activityId: this.currentData.id }).then(res => {
          this.success('操作成功')
          this.getCurrentData()
          this.activeName = 'first'
        })
      })
    },

    closeFile() {
      this.showFinancialInformation = false
      this.fileList = []
      this.$refs.fileForm.resetFields()
    },

    handleClick(v) {
      switch (v.name) {
        case 'first':
          this.getCurrentData()
          break
        case 'second':
          this.getPageData({ applyType: '辅助器具' })
          break
        case 'basic':
          this.getPageData({ applyType: '基本服务' })
          break
      }
    },

    getCurrentData() {
      this.API.getAssistActivityDetailInfoById({ id: this.$route.query.id }).then(res => {
        this.currentData = res.data
      })
    },

    search(val) {
      this.getPageData({ applyType: val })
    },

    clear(val) {
      this.region = [];
      this.$refs.form.resetFields()
      this.$refs.form1.resetFields()
      this.getPageData({ applyType: val })
    },

    getPageData(val) {
      this.searchDto.region = this.region.length ? this.region[this.region.length - 1] : null
      let tem = Object.assign(this.searchDto, { activityId: this.currentData.id }, val);
      this.API.getApplyUserPageInfoById(tem).then(res => {
        this.pageData = res.data;
      });
    },

    submitFinance() {
      this.$confirm("确认上传财政吗?", "提示", { type: "warning" }).then(() => {
        this.API.submitFinance({ activityId: this.currentData.id }).then(res => {
          this.success('操作成功')
          this.getCurrentData()
          this.activeName = 'first'
        })
      })
    },
    financialInformation() {
      this.showFinancialInformation = true
      this.API.serviceInfo({ activityId: this.currentData.id }).then(res => {
        this.serviceList = res.data
        this.serviceList.map(v => {
          const defaultObj = v.serviceInfos.find(info => info.flag)
          this.$set(v, 'current', defaultObj || null)
        })
      })
    },

    // 鉴定机构
    chooseBodies() {
      this.API.getInstituteList({ activityId: this.currentData.id }).then(res => {
        this.serviceList = res.data
        this.serviceList.map(v => this.$set(v, 'current', null))
        this.showChooseBodies = true
      })
    },
    confirmBodies() {
      this.formInfo1.instituteInfoDtos = []
      this.serviceList.map(v => {
        const { current, disabledTypeId, disabledTypeName } = v
        if (current) {
          let tem = _.cloneDeep(current)
          this.formInfo1.instituteInfoDtos.push(
            Object.assign(tem, { disabledTypeId, disabledTypeName })
          )
        }
      })
      this.$refs["fileForm1"].validate(valid => {
        if (valid) {
          this.$confirm("确认选择机构?", "提示", { type: "warning" }).then(() => {
            this.API.chooseInstitute({ activityId: this.currentData.id, body: this.formInfo1 }).then(res => {
              this.success('操作成功')
              this.close()
              this.getCurrentData()
              this.activeName = 'first'
            })
          })
        }
      })
    },
    confirm() {
      this.formInfo.submitFileServiceInfoDtos = []
      this.serviceList.map(v => {
        const { current, disabledTypeId, disabledTypeName } = v
        if (current) {
          let tem = _.cloneDeep(current)
          delete tem.flag
          this.formInfo.submitFileServiceInfoDtos.push(
            Object.assign(tem, { disabledTypeId, disabledTypeName })
          )
        }
      })
      this.$refs["fileForm"].validate(valid => {
        if (valid) {
          this.$confirm("确认上传财政资料吗?", "提示", { type: "warning" }).then(() => {
            this.API.submitFile({ activityId: this.currentData.id, body: this.formInfo }).then(res => {
              this.success('操作成功')
              this.closeFile()
              this.getCurrentData()
              this.activeName = 'first'
            })
          })
        }
      })
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 5 个文件，本次选择了 ${
          files.length
        } 个文件，共选择了 ${files.length + fileList.length} 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    //上传成功
    handleSuccess(res, file, fileList) {
      this.formInfo.financeUrl = "";
      let ids = [];
      fileList.map(item => {
        if (item.response && item.response.id) {
          ids.push(item.response);
        }
      });
      this.formInfo.financeUrl = JSON.stringify(ids);
    },
    handleRemove(file, fileList) {
      this.formInfo.financeUrl = "";
      let ids = [];
      fileList.map(item => {
        if (item.response && item.response.id) {
          ids.push(item.response);
        }
      });
      this.formInfo.financeUrl = ids.length ? JSON.stringify(ids) : '';
    },
  },
  mounted() {
    this.getCurrentData()
  }
}
</script>
<style scoped lang="scss">
  .app-container {
    padding: 20px;
    margin-top: 10px;
  }

  .bottom-btn {
    display: flex;
    justify-content: center;
  }
</style>
